package com.ziki.link.api.v1;

import com.alibaba.nacos.shaded.org.checkerframework.checker.index.qual.Positive;
import com.ziki.common.model.vo.Response;
import com.ziki.link.api.v1.request.LinkCreateRequest;
import com.ziki.link.model.LinkGroupDO;
import com.ziki.link.service.LinkTestService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author pty
 * @version V1.0
 * @Package com.ziki.link.api.v1
 * @date 2024/4/25 18:51
 */
@RestController
@RequestMapping("/test/v1")
@Validated
public class LinkTestController {

    private LinkTestService linkTestService;

    @PostMapping("create")
    public Response<Void> create(@RequestBody LinkCreateRequest requestO) {
        this.linkTestService.create(requestO);
        return Response.success();
    }


    @DeleteMapping("/{test_id}")
    public Response<Void> del(@RequestAttribute("test_id") @Positive long testId) {
        this.linkTestService.del(testId);
        return Response.success();
    }

    @GetMapping("/{test_id}")
    public Response<LinkGroupDO> fineOne(@RequestAttribute("test_id") @Positive Long testId) {
        LinkGroupDO linkGroupDO = this.linkTestService.findOne(testId);
        return Response.success(linkGroupDO);
    }


    @GetMapping("/list")
    public Response<List<LinkGroupDO>> findAll() {
        List<LinkGroupDO> list = this.linkTestService.findAll();
        return Response.success(list);
    }
     

}
